home *** CD-ROM | disk | FTP | other *** search
/ Aminet 48 / Aminet 48 (2002)(GTI - Schatztruhe)[!][Apr 2002].iso / Aminet / dev / cross / 6502d.lha / disasm.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-01-26  |  33.8 KB  |  784 lines

  1. /*****************************************************************************
  2. * 6502D Version 0.1                                                          *
  3. * Bart Trzynadlowski, 1999                                                   *
  4. *                                                                            *
  5. * Feel free to do whatever you wish with this source code provided that you  *
  6. * understand it is provided "as is" and that the author will not be held     *
  7. * responsible for anything that happens because of this software.            *
  8. *                                                                            *
  9. * disasm.c: Contains function to disassemble and print mnemonics.            *
  10. *****************************************************************************/
  11.  
  12. #include <stdio.h>
  13. #include "opcode.h"
  14.  
  15. /*****************************************************************************
  16. * disasm: Prints the opcode passed to it and updates the main program        *
  17. * counter passed to it via a pointer.                                        *
  18. *****************************************************************************/
  19. int disasm(unsigned char opcode, int *p, FILE *infile)
  20. {
  21.         unsigned char opcode2;
  22.         unsigned char opcode3;
  23.  
  24.         /* (address+origin)+tab+op_byte1 */
  25.         printf("%08X:\t%02X", *p, opcode);
  26.  
  27.         /* print ... keep in mind that 6502 is little-endian */
  28.         switch (opcode)
  29.         {
  30.                 default:
  31.                         printf("\t.DB $%02X", opcode);                       
  32.                         break;
  33.                 case ADC_IMMED:
  34.                         opcode2=fgetc(infile);
  35.                         (*p)++;
  36.                         printf("%02X\tADC #$%02X", opcode2, opcode2);
  37.                         break;
  38.                 case ADC_ZEROPAGE:
  39.                         opcode2=fgetc(infile);
  40.                         (*p)++;
  41.                         printf("%02X\tADC $%02X", opcode2, opcode2);
  42.                         break;
  43.                 case ADC_ZEROPAGE_X:
  44.                         opcode2=fgetc(infile);
  45.                         (*p)++;
  46.                         printf("%02X\tADC $%02X,X", opcode2, opcode2);
  47.                         break;
  48.                 case ADC_ABSOLUTE:
  49.                         opcode2=fgetc(infile);
  50.                         opcode3=fgetc(infile);
  51.                         *p=*p+2;
  52.                         printf("%02X%02X\tADC $%02X%02X", opcode2, opcode3, opcode3, opcode2);
  53.                         break;
  54.                 case ADC_ABSOLUTE_X:
  55.                         opcode2=fgetc(infile);
  56.                         opcode3=fgetc(infile);
  57.                         *p=*p+2;
  58.                         printf("%02X%02X\tADC $%02X%02X,X", opcode2, opcode3, opcode3, opcode2);
  59.                         break;
  60.                 case ADC_ABSOLUTE_Y:
  61.                         opcode2=fgetc(infile);
  62.                         opcode3=fgetc(infile);
  63.                         *p=*p+2;
  64.                         printf("%02X%02X\tADC $%02X%02X,Y", opcode2, opcode3, opcode3, opcode2);
  65.                         break;                       
  66.                 case ADC_INDIRECT_X:
  67.                         opcode2=fgetc(infile);
  68.                         (*p)++;
  69.                         printf("%02X\tADC ($%02X,X)", opcode2, opcode2);
  70.                         break;
  71.                 case ADC_INDIRECT_Y:
  72.                         opcode2=fgetc(infile);
  73.                         (*p)++;
  74.                         printf("%02X\tADC ($%02X),Y", opcode2, opcode2);
  75.                         break;
  76.                 case AND_IMMED:
  77.                         opcode2=fgetc(infile);
  78.                         (*p)++;
  79.                         printf("%02X\tAND #$%02X", opcode2, opcode2);
  80.                         break;
  81.                 case AND_ZEROPAGE:
  82.                         opcode2=fgetc(infile);
  83.                         (*p)++;
  84.                         printf("%02X\tAND $%02X", opcode2, opcode2);
  85.                         break;
  86.                 case AND_ZEROPAGE_X:
  87.                         opcode2=fgetc(infile);
  88.                         (*p)++;
  89.                         printf("%02X\tAND $%02X,X", opcode2, opcode2);
  90.                         break;
  91.                 case AND_ABSOLUTE:
  92.                         opcode2=fgetc(infile);
  93.                         opcode3=fgetc(infile);
  94.                         *p=*p+2;
  95.                         printf("%02X%02X\tAND $%02X%02X", opcode2, opcode3, opcode3, opcode2);
  96.                         break;
  97.                 case AND_ABSOLUTE_X:
  98.                         opcode2=fgetc(infile);
  99.                         opcode3=fgetc(infile);
  100.                         *p=*p+2;
  101.                         printf("%02X%02X\tAND $%02X%02X,X", opcode2, opcode3, opcode3, opcode2);
  102.                         break;
  103.                 case AND_ABSOLUTE_Y:
  104.                         opcode2=fgetc(infile);
  105.                         opcode3=fgetc(infile);
  106.                         *p=*p+2;
  107.                         printf("%02X%02X\tAND $%02X%02X,Y", opcode2, opcode3, opcode3, opcode2);
  108.                         break;                       
  109.                 case AND_INDIRECT_X:
  110.                         opcode2=fgetc(infile);
  111.                         (*p)++;
  112.                         printf("%02X\tAND ($%02X,X)", opcode2, opcode2);
  113.                         break;
  114.                 case AND_INDIRECT_Y:
  115.                         opcode2=fgetc(infile);
  116.                         (*p)++;
  117.                         printf("%02X\tAND ($%02X),Y", opcode2, opcode2);
  118.                         break;
  119.                 case ASL_A:
  120.                         printf("\tASL A");
  121.                         break;
  122.                 case ASL_ZEROPAGE:
  123.                         opcode2=fgetc(infile);
  124.                         (*p)++;
  125.                         printf("%02X\tASL $%02X", opcode2, opcode2);
  126.                         break;
  127.                 case ASL_ZEROPAGE_X:
  128.                         opcode2=fgetc(infile);
  129.                         (*p)++;
  130.                         printf("%02X\tASL $%02X,X", opcode2, opcode2);
  131.                         break;
  132.                 case ASL_ABSOLUTE:
  133.                         opcode2=fgetc(infile);
  134.                         opcode3=fgetc(infile);
  135.                         *p=*p+2;
  136.                         printf("%02X%02X\tASL $%02X%02X", opcode2, opcode3, opcode3, opcode2);
  137.                         break;
  138.                 case ASL_ABSOLUTE_X:
  139.                         opcode2=fgetc(infile);
  140.                         opcode3=fgetc(infile);
  141.                         *p=*p+2;
  142.                         printf("%02X%02X\tASL $%02X%02X,X", opcode2, opcode3, opcode3, opcode2);
  143.                         break;
  144.                 case BCC:
  145.                         opcode2=fgetc(infile);
  146.                         (*p)++;
  147.                         printf("%02X\tBCC $%02X", opcode2, opcode2);
  148.                         break;
  149.                 case BCS:
  150.                         opcode2=fgetc(infile);
  151.                         (*p)++;
  152.                         printf("%02X\tBCS $%02X", opcode2, opcode2);
  153.                         break;
  154.                 case BEQ:
  155.                         opcode2=fgetc(infile);
  156.                         (*p)++;
  157.                         printf("%02X\tBEQ $%02X", opcode2, opcode2);
  158.                         break;
  159.                 case BIT_ZEROPAGE:
  160.                         opcode2=fgetc(infile);
  161.                         (*p)++;
  162.                         printf("%02X\tBIT $%02X", opcode2, opcode2);
  163.                         break;
  164.                 case BIT_ABSOLUTE:
  165.                         opcode2=fgetc(infile);
  166.                         opcode3=fgetc(infile);
  167.                         *p=*p+2;
  168.                         printf("%02X%02X\tBIT $%02X%02X", opcode2, opcode3, opcode3, opcode2);
  169.                         break;
  170.                 case BMI:
  171.                         opcode2=fgetc(infile);
  172.                         (*p)++;
  173.                         printf("%02X\tBMI $%02X", opcode2, opcode2);
  174.                         break;
  175.                 case BNE:
  176.                         opcode2=fgetc(infile);
  177.                         (*p)++;
  178.                         printf("%02X\tBNE $%02X", opcode2, opcode2);
  179.                         break;
  180.                 case BPL:
  181.                         opcode2=fgetc(infile);
  182.                         (*p)++;
  183.                         printf("%02X\tBPL $%02X", opcode2, opcode2);
  184.                         break;
  185.                 case BRK:
  186.                         printf("\tBRK");
  187.                         break;
  188.                 case BVC:
  189.                         opcode2=fgetc(infile);
  190.                         (*p)++;
  191.                         printf("%02X\tBVC $%02X", opcode2, opcode2);
  192.                         break;
  193.                 case BVS:
  194.                         opcode2=fgetc(infile);
  195.                         (*p)++;
  196.                         printf("%02X\tBVS $%02X", opcode2, opcode2);
  197.                         break;
  198.                 case CLC:
  199.                         printf("\tCLC");
  200.                         break;
  201.                 case CLD:
  202.                         printf("\tCLD");
  203.                         break;
  204.                 case CLI:
  205.                         printf("\tCLI");
  206.                         break;
  207.                 case CLV:
  208.                         printf("\tCLV");
  209.                         break;
  210.                 case CMP_IMMED:
  211.                         opcode2=fgetc(infile);
  212.                         (*p)++;
  213.                         printf("%02X\tCMP #$%02X", opcode2, opcode2);
  214.                         break;
  215.                 case CMP_ZEROPAGE:
  216.                         opcode2=fgetc(infile);
  217.                         (*p)++;
  218.                         printf("%02X\tCMP $%02X", opcode2, opcode2);
  219.                         break;
  220.                 case CMP_ZEROPAGE_X:
  221.                         opcode2=fgetc(infile);
  222.                         (*p)++;
  223.                         printf("%02X\tCMP $%02X,X", opcode2, opcode2);
  224.                         break;
  225.                 case CMP_ABSOLUTE:
  226.                         opcode2=fgetc(infile);
  227.                         opcode3=fgetc(infile);
  228.                         *p=*p+2;
  229.                         printf("%02X%02X\tCMP $%02X%02X", opcode2, opcode3, opcode3, opcode2);
  230.                         break;
  231.                 case CMP_ABSOLUTE_X:
  232.                         opcode2=fgetc(infile);
  233.                         opcode3=fgetc(infile);
  234.                         *p=*p+2;
  235.                         printf("%02X%02X\tCMP $%02X%02X,X", opcode2, opcode3, opcode3, opcode2);
  236.                         break;
  237.                 case CMP_ABSOLUTE_Y:
  238.                         opcode2=fgetc(infile);
  239.                         opcode3=fgetc(infile);
  240.                         *p=*p+2;
  241.                         printf("%02X%02X\tCMP $%02X%02X,Y", opcode2, opcode3, opcode3, opcode2);
  242.                         break;                       
  243.                 case CMP_INDIRECT_X:
  244.                         opcode2=fgetc(infile);
  245.                         (*p)++;
  246.                         printf("%02X\tCMP ($%02X,X)", opcode2, opcode2);
  247.                         break;
  248.                 case CMP_INDIRECT_Y:
  249.                         opcode2=fgetc(infile);
  250.                         (*p)++;
  251.                         printf("%02X\tCMP ($%02X),Y", opcode2, opcode2);
  252.                         break;
  253.                 case CPX_IMMED:
  254.                         opcode2=fgetc(infile);
  255.                         (*p)++;
  256.                         printf("%02X\tCPX #$%02X", opcode2, opcode2);
  257.                         break;
  258.                 case CPX_ZEROPAGE:
  259.                         opcode2=fgetc(infile);
  260.                         (*p)++;
  261.                         printf("%02X\tCPX $%02X", opcode2, opcode2);
  262.                         break;
  263.                 case CPX_ABSOLUTE:
  264.                         opcode2=fgetc(infile);
  265.                         opcode3=fgetc(infile);
  266.                         *p=*p+2;
  267.                         printf("%02X%02X\tCPX $%02X%02X", opcode2, opcode3, opcode3, opcode2);
  268.                         break;
  269.                 case CPY_IMMED:
  270.                         opcode2=fgetc(infile);
  271.                         (*p)++;
  272.                         printf("%02X\tCPY #$%02X", opcode2, opcode2);
  273.                         break;
  274.                 case CPY_ZEROPAGE:
  275.                         opcode2=fgetc(infile);
  276.                         (*p)++;
  277.                         printf("%02X\tCPY $%02X", opcode2, opcode2);
  278.                         break;
  279.                 case CPY_ABSOLUTE:
  280.                         opcode2=fgetc(infile);
  281.                         opcode3=fgetc(infile);
  282.                         *p=*p+2;
  283.                         printf("%02X%02X\tCPY $%02X%02X", opcode2, opcode3, opcode3, opcode2);
  284.                         break;
  285.                 case DEC_ZEROPAGE:
  286.                         opcode2=fgetc(infile);
  287.                         (*p)++;
  288.                         printf("%02X\tDEC $%02X", opcode2, opcode2);
  289.                         break;
  290.                 case DEC_ZEROPAGE_X:
  291.                         opcode2=fgetc(infile);
  292.                         (*p)++;
  293.                         printf("%02X\tDEC $%02X,X", opcode2, opcode2);
  294.                         break;
  295.                 case DEC_ABSOLUTE:
  296.                         opcode2=fgetc(infile);
  297.                         opcode3=fgetc(infile);
  298.                         *p=*p+2;
  299.                         printf("%02X%02X\tDEC $%02X%02X", opcode2, opcode3, opcode3, opcode2);
  300.                         break;
  301.                 case DEC_ABSOLUTE_X:
  302.                         opcode2=fgetc(infile);
  303.                         opcode3=fgetc(infile);
  304.                         *p=*p+2;
  305.                         printf("%02X%02X\tDEC $%02X%02X,X", opcode2, opcode3, opcode3, opcode2);
  306.                         break;
  307.                 case DEX:
  308.                         printf("\tDEX");
  309.                         break;
  310.                 case DEY:
  311.                         printf("\tDEY");
  312.                         break;
  313.                 case EOR_IMMED:
  314.                         opcode2=fgetc(infile);
  315.                         (*p)++;
  316.                         printf("%02X\tEOR #$%02X", opcode2, opcode2);
  317.                         break;
  318.                 case EOR_ZEROPAGE:
  319.                         opcode2=fgetc(infile);
  320.                         (*p)++;
  321.                         printf("%02X\tEOR $%02X", opcode2, opcode2);
  322.                         break;
  323.                 case EOR_ZEROPAGE_X:
  324.                         opcode2=fgetc(infile);
  325.                         (*p)++;
  326.                         printf("%02X\tEOR $%02X,X", opcode2, opcode2);
  327.                         break;
  328.                 case EOR_ABSOLUTE:
  329.                         opcode2=fgetc(infile);
  330.                         opcode3=fgetc(infile);
  331.                         *p=*p+2;
  332.                         printf("%02X%02X\tEOR $%02X%02X", opcode2, opcode3, opcode3, opcode2);
  333.                         break;
  334.                 case EOR_ABSOLUTE_X:
  335.                         opcode2=fgetc(infile);
  336.                         opcode3=fgetc(infile);
  337.                         *p=*p+2;
  338.                         printf("%02X%02X\tEOR $%02X%02X,X", opcode2, opcode3, opcode3, opcode2);
  339.                         break;
  340.                 case EOR_ABSOLUTE_Y:
  341.                         opcode2=fgetc(infile);
  342.                         opcode3=fgetc(infile);
  343.                         *p=*p+2;
  344.                         printf("%02X%02X\tEOR $%02X%02X,Y", opcode2, opcode3, opcode3, opcode2);
  345.                         break;                       
  346.                 case EOR_INDIRECT_X:
  347.                         opcode2=fgetc(infile);
  348.                         (*p)++;
  349.                         printf("%02X\tEOR ($%02X,X)", opcode2, opcode2);
  350.                         break;
  351.                 case EOR_INDIRECT_Y:
  352.                         opcode2=fgetc(infile);
  353.                         (*p)++;
  354.                         printf("%02X\tEOR ($%02X),Y", opcode2, opcode2);
  355.                         break;                       
  356.                 case INC_ZEROPAGE:
  357.                         opcode2=fgetc(infile);
  358.                         (*p)++;
  359.                         printf("%02X\tINC $%02X", opcode2, opcode2);
  360.                         break;
  361.                 case INC_ZEROPAGE_X:
  362.                         opcode2=fgetc(infile);
  363.                         (*p)++;
  364.                         printf("%02X\tINC $%02X,X", opcode2, opcode2);
  365.                         break;
  366.                 case INC_ABSOLUTE:
  367.                         opcode2=fgetc(infile);
  368.                         opcode3=fgetc(infile);
  369.                         *p=*p+2;
  370.                         printf("%02X%02X\tINC $%02X%02X", opcode2, opcode3, opcode3, opcode2);
  371.                         break;
  372.                 case INC_ABSOLUTE_X:
  373.                         opcode2=fgetc(infile);
  374.                         opcode3=fgetc(infile);
  375.                         *p=*p+2;
  376.                         printf("%02X%02X\tINC $%02X%02X,X", opcode2, opcode3, opcode3, opcode2);
  377.                         break;
  378.                 case INX:
  379.                         printf("\tINX");
  380.                         break;
  381.                 case INY:
  382.                         printf("\tINY");
  383.                         break;
  384.                 case JMP_ABSOLUTE:
  385.                         opcode2=fgetc(infile);
  386.                         opcode3=fgetc(infile);
  387.                         *p=*p+2;
  388.                         printf("%02X%02X\tJMP $%02X%02X", opcode2, opcode3, opcode3, opcode2);
  389.                         break;
  390.                 case JMP_INDIRECT:
  391.                         opcode2=fgetc(infile);
  392.                         opcode3=fgetc(infile);
  393.                         *p=*p+2;
  394.                         printf("%02X%02X\tJMP ($%02X%02X)", opcode2, opcode3, opcode3, opcode2);
  395.                         break;
  396.                 case JSR:
  397.                         opcode2=fgetc(infile);
  398.                         opcode3=fgetc(infile);
  399.                         *p=*p+2;
  400.                         printf("%02X%02X\tJSR $%02X%02X", opcode2, opcode3, opcode3, opcode2);
  401.                         break;
  402.                 case LDA_IMMED:
  403.                         opcode2=fgetc(infile);
  404.                         (*p)++;
  405.                         printf("%02X\tLDA #$%02X", opcode2, opcode2);
  406.                         break;
  407.                 case LDA_ZEROPAGE:
  408.                         opcode2=fgetc(infile);
  409.                         (*p)++;
  410.                         printf("%02X\tLDA $%02X", opcode2, opcode2);
  411.                         break;
  412.                 case LDA_ZEROPAGE_X:
  413.                         opcode2=fgetc(infile);
  414.                         (*p)++;
  415.                         printf("%02X\tLDA $%02X,X", opcode2, opcode2);
  416.                         break;
  417.                 case LDA_ABSOLUTE:
  418.                         opcode2=fgetc(infile);
  419.                         opcode3=fgetc(infile);
  420.                         *p=*p+2;
  421.                         printf("%02X%02X\tLDA $%02X%02X", opcode2, opcode3, opcode3, opcode2);
  422.                         break;
  423.                 case LDA_ABSOLUTE_X:
  424.                         opcode2=fgetc(infile);
  425.                         opcode3=fgetc(infile);
  426.                         *p=*p+2;
  427.                         printf("%02X%02X\tLDA $%02X%02X,X", opcode2, opcode3, opcode3, opcode2);
  428.                         break;
  429.                 case LDA_ABSOLUTE_Y:
  430.                         opcode2=fgetc(infile);
  431.                         opcode3=fgetc(infile);
  432.                         *p=*p+2;
  433.                         printf("%02X%02X\tLDA $%02X%02X,Y", opcode2, opcode3, opcode3, opcode2);
  434.                         break;                       
  435.                 case LDA_INDIRECT_X:
  436.                         opcode2=fgetc(infile);
  437.                         (*p)++;
  438.                         printf("%02X\tLDA ($%02X,X)", opcode2, opcode2);
  439.                         break;
  440.                 case LDA_INDIRECT_Y:
  441.                         opcode2=fgetc(infile);
  442.                         (*p)++;
  443.                         printf("%02X\tLDA ($%02X),Y", opcode2, opcode2);
  444.                         break;                       
  445.                 case LDX_IMMED:
  446.                         opcode2=fgetc(infile);
  447.                         (*p)++;
  448.                         printf("%02X\tLDX #$%02X", opcode2, opcode2);
  449.                         break;
  450.                 case LDX_ZEROPAGE:
  451.                         opcode2=fgetc(infile);
  452.                         (*p)++;
  453.                         printf("%02X\tLDX $%02X", opcode2, opcode2);
  454.                         break;
  455.                 case LDX_ZEROPAGE_Y:
  456.                         opcode2=fgetc(infile);
  457.                         (*p)++;
  458.                         printf("%02X\tLDX $%02X,Y", opcode2, opcode2);
  459.                         break;
  460.                 case LDX_ABSOLUTE:
  461.                         opcode2=fgetc(infile);
  462.                         opcode3=fgetc(infile);
  463.                         *p=*p+2;
  464.                         printf("%02X%02X\tLDX $%02X%02X", opcode2, opcode3, opcode3, opcode2);
  465.                         break;
  466.                 case LDX_ABSOLUTE_Y:
  467.                         opcode2=fgetc(infile);
  468.                         opcode3=fgetc(infile);
  469.                         *p=*p+2;
  470.                         printf("%02X%02X\tLDX $%02X%02X,Y", opcode2, opcode3, opcode3, opcode2);
  471.                         break;
  472.                 case LDY_IMMED:
  473.                         opcode2=fgetc(infile);
  474.                         (*p)++;
  475.                         printf("%02X\tLDY #$%02X", opcode2, opcode2);
  476.                         break;
  477.                 case LDY_ZEROPAGE:
  478.                         opcode2=fgetc(infile);
  479.                         (*p)++;
  480.                         printf("%02X\tLDY $%02X", opcode2, opcode2);
  481.                         break;
  482.                 case LDY_ZEROPAGE_X:
  483.                         opcode2=fgetc(infile);
  484.                         (*p)++;
  485.                         printf("%02X\tLDY $%02X,X", opcode2, opcode2);
  486.                         break;
  487.                 case LDY_ABSOLUTE:
  488.                         opcode2=fgetc(infile);
  489.                         opcode3=fgetc(infile);
  490.                         *p=*p+2;
  491.                         printf("%02X%02X\tLDY $%02X%02X", opcode2, opcode3, opcode3, opcode2);
  492.                         break;
  493.                 case LDY_ABSOLUTE_X:
  494.                         opcode2=fgetc(infile);
  495.                         opcode3=fgetc(infile);
  496.                         *p=*p+2;
  497.                         printf("%02X%02X\tLDY $%02X%02X,X", opcode2, opcode3, opcode3, opcode2);
  498.                         break;
  499.                 case LSR_A:
  500.                         printf("\tLSR A");
  501.                         break;
  502.                 case LSR_ZEROPAGE:
  503.                         opcode2=fgetc(infile);
  504.                         (*p)++;
  505.                         printf("%02X\tLSR $%02X", opcode2, opcode2);
  506.                         break;
  507.                 case LSR_ZEROPAGE_X:
  508.                         opcode2=fgetc(infile);
  509.                         (*p)++;
  510.                         printf("%02X\tLSR $%02X,X", opcode2, opcode2);
  511.                         break;
  512.                 case LSR_ABSOLUTE:
  513.                         opcode2=fgetc(infile);
  514.                         opcode3=fgetc(infile);
  515.                         *p=*p+2;
  516.                         printf("%02X%02X\tLSR $%02X%02X", opcode2, opcode3, opcode3, opcode2);
  517.                         break;
  518.                 case LSR_ABSOLUTE_X:
  519.                         opcode2=fgetc(infile);
  520.                         opcode3=fgetc(infile);
  521.                         *p=*p+2;
  522.                         printf("%02X%02X\tLSR $%02X%02X,X", opcode2, opcode3, opcode3, opcode2);
  523.                         break;
  524.                 case NOP:
  525.                         printf("\tNOP");
  526.                         break;
  527.                 case ORA_IMMED:
  528.                         opcode2=fgetc(infile);
  529.                         (*p)++;
  530.                         printf("%02X\tORA #$%02X", opcode2, opcode2);
  531.                         break;
  532.                 case ORA_ZEROPAGE:
  533.                         opcode2=fgetc(infile);
  534.                         (*p)++;
  535.                         printf("%02X\tORA $%02X", opcode2, opcode2);
  536.                         break;
  537.                 case ORA_ZEROPAGE_X:
  538.                         opcode2=fgetc(infile);
  539.                         (*p)++;
  540.                         printf("%02X\tORA $%02X,X", opcode2, opcode2);
  541.                         break;
  542.                 case ORA_ABSOLUTE:
  543.                         opcode2=fgetc(infile);
  544.                         opcode3=fgetc(infile);
  545.                         *p=*p+2;
  546.                         printf("%02X%02X\tORA $%02X%02X", opcode2, opcode3, opcode3, opcode2);
  547.                         break;
  548.                 case ORA_ABSOLUTE_X:
  549.                         opcode2=fgetc(infile);
  550.                         opcode3=fgetc(infile);
  551.                         *p=*p+2;
  552.                         printf("%02X%02X\tORA $%02X%02X,X", opcode2, opcode3, opcode3, opcode2);
  553.                         break;
  554.                 case ORA_ABSOLUTE_Y:
  555.                         opcode2=fgetc(infile);
  556.                         opcode3=fgetc(infile);
  557.                         *p=*p+2;
  558.                         printf("%02X%02X\tORA $%02X%02X,Y", opcode2, opcode3, opcode3, opcode2);
  559.                         break;                       
  560.                 case ORA_INDIRECT_X:
  561.                         opcode2=fgetc(infile);
  562.                         (*p)++;
  563.                         printf("%02X\tORA ($%02X,X)", opcode2, opcode2);
  564.                         break;
  565.                 case ORA_INDIRECT_Y:
  566.                         opcode2=fgetc(infile);
  567.                         (*p)++;
  568.                         printf("%02X\tORA ($%02X),Y", opcode2, opcode2);
  569.                         break;
  570.                 case PHA:
  571.                         printf("\tPHA");
  572.                         break;
  573.                 case PHP:
  574.                         printf("\tPHP");
  575.                         break;
  576.                 case PLA:
  577.                         printf("\tPLA");
  578.                         break;
  579.                 case PLP:
  580.                         printf("\tPLP");
  581.                         break;
  582.                 case ROL_A:
  583.                         printf("\tROL A");
  584.                         break;
  585.                 case ROL_ZEROPAGE:
  586.                         opcode2=fgetc(infile);
  587.                         (*p)++;
  588.                         printf("%02X\tROL $%02X", opcode2, opcode2);
  589.                         break;
  590.                 case ROL_ZEROPAGE_X:
  591.                         opcode2=fgetc(infile);
  592.                         (*p)++;
  593.                         printf("%02X\tROL $%02X,X", opcode2, opcode2);
  594.                         break;
  595.                 case ROL_ABSOLUTE:
  596.                         opcode2=fgetc(infile);
  597.                         opcode3=fgetc(infile);
  598.                         *p=*p+2;
  599.                         printf("%02X%02X\tROL $%02X%02X", opcode2, opcode3, opcode3, opcode2);
  600.                         break;
  601.                 case ROL_ABSOLUTE_X:
  602.                         opcode2=fgetc(infile);
  603.                         opcode3=fgetc(infile);
  604.                         *p=*p+2;
  605.                         printf("%02X%02X\tROL $%02X%02X,X", opcode2, opcode3, opcode3, opcode2);
  606.                         break;
  607.                 case ROR_A:
  608.                         printf("\tROR A");
  609.                         break;
  610.                 case ROR_ZEROPAGE:
  611.                         opcode2=fgetc(infile);
  612.                         (*p)++;
  613.                         printf("%02X\tROR $%02X", opcode2, opcode2);
  614.                         break;
  615.                 case ROR_ZEROPAGE_X:
  616.                         opcode2=fgetc(infile);
  617.                         (*p)++;
  618.                         printf("%02X\tROR $%02X,X", opcode2, opcode2);
  619.                         break;
  620.                 case ROR_ABSOLUTE:
  621.                         opcode2=fgetc(infile);
  622.                         opcode3=fgetc(infile);
  623.                         *p=*p+2;
  624.                         printf("%02X%02X\tROR $%02X%02X", opcode2, opcode3, opcode3, opcode2);
  625.                         break;
  626.                 case ROR_ABSOLUTE_X:
  627.                         opcode2=fgetc(infile);
  628.                         opcode3=fgetc(infile);
  629.                         *p=*p+2;
  630.                         printf("%02X%02X\tROR $%02X%02X,X", opcode2, opcode3, opcode3, opcode2);
  631.                         break;
  632.                 case RTI:
  633.                         printf("\tRTI");
  634.                         break;
  635.                 case RTS:
  636.                         printf("\tRTS");
  637.                         break;
  638.                 case SBC_IMMED:
  639.                         opcode2=fgetc(infile);
  640.                         (*p)++;
  641.                         printf("%02X\tSBC #$%02X", opcode2, opcode2);
  642.                         break;
  643.                 case SBC_ZEROPAGE:
  644.                         opcode2=fgetc(infile);
  645.                         (*p)++;
  646.                         printf("%02X\tSBC $%02X", opcode2, opcode2);
  647.                         break;
  648.                 case SBC_ZEROPAGE_X:
  649.                         opcode2=fgetc(infile);
  650.                         (*p)++;
  651.                         printf("%02X\tSBC $%02X,X", opcode2, opcode2);
  652.                         break;
  653.                 case SBC_ABSOLUTE:
  654.                         opcode2=fgetc(infile);
  655.                         opcode3=fgetc(infile);
  656.                         *p=*p+2;
  657.                         printf("%02X%02X\tSBC $%02X%02X", opcode2, opcode3, opcode3, opcode2);
  658.                         break;
  659.                 case SBC_ABSOLUTE_X:
  660.                         opcode2=fgetc(infile);
  661.                         opcode3=fgetc(infile);
  662.                         *p=*p+2;
  663.                         printf("%02X%02X\tSBC $%02X%02X,X", opcode2, opcode3, opcode3, opcode2);
  664.                         break;
  665.                 case SBC_ABSOLUTE_Y:
  666.                         opcode2=fgetc(infile);
  667.                         opcode3=fgetc(infile);
  668.                         *p=*p+2;
  669.                         printf("%02X%02X\tSBC $%02X%02X,Y", opcode2, opcode3, opcode3, opcode2);
  670.                         break;                       
  671.                 case SBC_INDIRECT_X:
  672.                         opcode2=fgetc(infile);
  673.                         (*p)++;
  674.                         printf("%02X\tSBC ($%02X,X)", opcode2, opcode2);
  675.                         break;
  676.                 case SBC_INDIRECT_Y:
  677.                         opcode2=fgetc(infile);
  678.                         (*p)++;
  679.                         printf("%02X\tSBC ($%02X),Y", opcode2, opcode2);
  680.                         break;
  681.                 case SEC:
  682.                         printf("\tSEC");
  683.                         break;
  684.                 case SED:
  685.                         printf("\tSED");
  686.                         break;
  687.                 case SEI:
  688.                         printf("\tSEI");
  689.                         break;
  690.                 case STA_ZEROPAGE:
  691.                         opcode2=fgetc(infile);
  692.                         (*p)++;
  693.                         printf("%02X\tSTA $%02X", opcode2, opcode2);
  694.                         break;
  695.                 case STA_ZEROPAGE_X:
  696.                         opcode2=fgetc(infile);
  697.                         (*p)++;
  698.                         printf("%02X\tSTA $%02X,X", opcode2, opcode2);
  699.                         break;
  700.                 case STA_ABSOLUTE:
  701.                         opcode2=fgetc(infile);
  702.                         opcode3=fgetc(infile);
  703.                         *p=*p+2;
  704.                         printf("%02X%02X\tSTA $%02X%02X", opcode2, opcode3, opcode3, opcode2);
  705.                         break;
  706.                 case STA_ABSOLUTE_X:
  707.                         opcode2=fgetc(infile);
  708.                         opcode3=fgetc(infile);
  709.                         *p=*p+2;
  710.                         printf("%02X%02X\tSTA $%02X%02X,X", opcode2, opcode3, opcode3, opcode2);
  711.                         break;
  712.                 case STA_ABSOLUTE_Y:
  713.                         opcode2=fgetc(infile);
  714.                         opcode3=fgetc(infile);
  715.                         *p=*p+2;
  716.                         printf("%02X%02X\tSTA $%02X%02X,Y", opcode2, opcode3, opcode3, opcode2);
  717.                         break;                       
  718.                 case STA_INDIRECT_X:
  719.                         opcode2=fgetc(infile);
  720.                         (*p)++;
  721.                         printf("%02X\tSTA ($%02X,X)", opcode2, opcode2);
  722.                         break;
  723.                 case STA_INDIRECT_Y:
  724.                         opcode2=fgetc(infile);
  725.                         (*p)++;
  726.                         printf("%02X\tSTA ($%02X),Y", opcode2, opcode2);
  727.                         break;
  728.                 case STX_ZEROPAGE:
  729.                         opcode2=fgetc(infile);
  730.                         (*p)++;
  731.                         printf("%02X\tSTX $%02X", opcode2, opcode2);
  732.                         break;
  733.                 case STX_ZEROPAGE_Y:
  734.                         opcode2=fgetc(infile);
  735.                         (*p)++;
  736.                         printf("%02X\tSTX $%02X,Y", opcode2, opcode2);
  737.                         break;
  738.                 case STX_ABSOLUTE:
  739.                         opcode2=fgetc(infile);
  740.                         opcode3=fgetc(infile);
  741.                         *p=*p+2;
  742.                         printf("%02X%02X\tSTX $%02X%02X", opcode2, opcode3, opcode3, opcode2);
  743.                         break;
  744.                 case STY_ZEROPAGE:
  745.                         opcode2=fgetc(infile);
  746.                         (*p)++;
  747.                         printf("%02X\tSTY $%02X", opcode2, opcode2);
  748.                         break;
  749.                 case STY_ZEROPAGE_X:
  750.                         opcode2=fgetc(infile);
  751.                         (*p)++;
  752.                         printf("%02X\tSTY $%02X,X", opcode2, opcode2);
  753.                         break;
  754.                 case STY_ABSOLUTE:
  755.                         opcode2=fgetc(infile);
  756.                         opcode3=fgetc(infile);
  757.                         *p=*p+2;
  758.                         printf("%02X%02X\tSTY $%02X%02X", opcode2, opcode3, opcode3, opcode2);
  759.                         break;
  760.                 case TAX:
  761.                         printf("\tTAX");
  762.                         break;
  763.                 case TAY:
  764.                         printf("\tTAY");
  765.                         break;
  766.                 case TSX:
  767.                         printf("\tTSX");
  768.                         break;
  769.                 case TXA:
  770.                         printf("\tTXA");
  771.                         break;
  772.                 case TXS:
  773.                         printf("\tTXS");
  774.                         break;
  775.                 case TYA:
  776.                         printf("\tTYA");
  777.                         break;                                                                             
  778.         }
  779.  
  780.         printf("\n");
  781.         return 0;
  782. }
  783.  
  784.